package org.footballmanager.pandafootball.system.form.impl;

import lombok.Getter;
import lombok.Setter;
import org.footballmanager.pandafootball.system.domain.FootBfinfo;
import org.footballmanager.pandafootball.system.domain.enums.BFLX;
import org.footballmanager.pandafootball.system.domain.enums.BFZT;
import org.footballmanager.pandafootball.system.form.SearchForm;
import org.springframework.util.StringUtils;
import tk.mybatis.mapper.entity.Example;

import java.io.Serializable;

@Getter
@Setter
public class FootBfinfoSearchForm extends SearchForm implements Serializable {
    private static final long serialVersionUID = 8090668615941861522L;
    protected BFZT bfzt;
    protected BFLX bflx;
    protected Long sj;
    protected String qdName;
    protected Long bfqd;
    protected Long bothQd;

    public Example buildSearchCommond() {
        Example example = new Example(FootBfinfo.class);
        Example.Criteria criteria = example.createCriteria();
        if (bfzt != null) {
            criteria.andEqualTo("bfzt", bfzt);
        }
        if (!StringUtils.isEmpty(sj)) {
            criteria.andEqualTo("sj", sj);
        }
        if (bflx != null) {
            criteria.andEqualTo("bflx", bflx);
        }
        if (!StringUtils.isEmpty(bfqd)) {
            criteria.andEqualTo("qd2", bfqd);
            Example.Criteria criteria2 = example.createCriteria();
            criteria2.andEqualTo("qd1", bfqd);
            example.or(criteria2);
        }
        criteria.andEqualTo("delFlag", 0);
        example.orderBy("sj").desc();
        return example;
    }

}
